package com.hss.recyclerviewtest.itemtouch;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;

import com.hss.recyclerviewtest.R;
import com.oushangfeng.pinnedsectionitemdecoration.PinnedHeaderItemDecoration;

public class DragRecyclerViewActivity extends AppCompatActivity {
    RecyclerView rcv;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        rcv = findViewById(R.id.rcv);
        rcv.setLayoutManager(new LinearLayoutManager(this));
        MyAdapter adapter = new MyAdapter();
        for (int i=0; i<50;i++){
            adapter.addData(String.valueOf(i+1));
        }
        rcv.setAdapter(adapter);


       ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(adapter);
        ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
        touchHelper.attachToRecyclerView(rcv);




    }
}
